<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib prefix="xdz" uri="/xdztools" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="${xdz:domain() }/css/bootstrap.min.css">
<link rel="stylesheet" href="${xdz:domain() }/css/font-awesome.min.css">
<link rel="stylesheet" href="${xdz:domain() }/css/parsley.css" >
<%-- <link rel="stylesheet" href="${xdz:domain() }/css/style.min.css"> --%>
<link rel="stylesheet" href="${xdz:domain() }/css/kkpager_blue.css">
<script src="${xdz:domain() }/js/jquery.min.js"></script>
<script src="${xdz:domain() }/js/jquery.treetable.js"></script>
<script src="${xdz:domain() }/js/bootstrap.min.js"></script>
<script src="${xdz:domain() }/js/plugins/fuelux/fuelux.js"></script>
<script src="${xdz:domain() }/js/underscore-min.js"></script>
<script src="${xdz:domain() }/js/plugins/dataTables/jquery.dataTables.js"></script>
<script src="${xdz:domain() }/js/app.js"></script>
<script src="${xdz:domain() }/js/app.plugin.js"></script>
<script src="${xdz:domain() }/js/app.data.js"></script>
<script src="${xdz:domain() }/js/kkpager.min.js"></script>
<script src="${xdz:domain() }/js/pagination.js"></script>
<script type="text/javascript" src="${xdz:domain() }/js/plugins/layer/layer.min.js"></script>
<title></title>
</head>
<body>
    <form <c:if test="${type eq 1 }">action="../readList"</c:if>  <c:if test="${type eq 2 }">action="../disreadList"</c:if> id="messageForm" method="post">
        <div class="panel panel-default">
        	<header class="panel-heading">
       			<h3 class="panel-title">消息列表</h3>
       		</header>
    		<div class="panel-body" style="padding:0px">
	    		<ul id="myTab" class="nav nav-tabs">
					  <li <c:if test="${type eq 1 }">class="active"</c:if>><a href="../readList">已读</a></li>
					  <li <c:if test="${type eq 2 }">class="active"</c:if>><a href="../disreadList">未读</a></li>
				</ul>
               <div class="table-responsive scroll-wrapper" >
                   <table class="table table-striped table-hover table-condensed" style="margin-bottom: 0;" >
                       <thead>
                           <tr>
<!--                                <th>主键</th> -->
                               <th>发送时间</th>
                               <th>信息标题</th>
                               <th>发送者</th>
                               <th>送至用户</th>
                               <th>送至角色</th>
                           </tr>
                       </thead>
                       <tbody>
                           <c:forEach var="list" items="${messageList }">
                               <tr>
<%--                                    <td>${list.id }</td> --%>
								   <td>${list.strSendtime }</td>
                                   <td>${list.title }</td>
                                   <td>${list.author }</td>
                                   <td>${list.touserName }</td>
                                   <td>${list.toroleName }</td>
                                   <td><a href="javascript:void(0)" onclick="showMessage('${list.title }','${list.content}',${list.id })" >查看消息</a></td>    
                              </tr>
                           </c:forEach>
                       </tbody>
                   </table>
            	</div>
            	 <div class="panel-footer">
                	<div id="kkpager"></div>
            	</div>
           </div>
       </div>
    </form>
    <script type="text/javascript">
    	var type='${type }';
    	function showMessage(title,content,id){
    		layer.open({
    			  type: 1, //page层
    			  area: ['50%', '50%'],
    			  title: title,
    			  shade: 0.6, //遮罩透明度
    			  moveType: 1, //拖拽风格，0是默认，1是传统拖动
    			  shift: 1, //0-6的动画形式，-1不开启
    			  content: '<div  style="padding:50px;">'+content+'</div>',
				  end:function(){
					  if(type==2){
			    			location.href="../disreadList";
			    		}
    			  }
    			});  
    		//ajax添加查看记录
	    	 $.ajax({
					url : "../addreadlog?_rnd="
							+ Math.random(10000000000),
					type : 'POST',
					data : {"messageId":id},
					dataType : 'json',
					success : function(data, status) {
					}
				});
    	}
    
		kkpager.generPageHtml({
			pno : '${extQuery.pageNum }',
			mode : 'click', //设置为click模式
			//总页码
			total : '${extQuery.totalPage}',
			//总数据条数 
			totalRecords : '${extQuery.total}',
			//点击页码、页码输入框跳转、以及首页、下一页等按钮都会调用click
			//适用于不刷新页面，比如ajax
			click : function(n){
				//这里可以做自已的处理
				//...
				this.selectPage(n);
				toPage(n, '${extQuery.totalPage}', 'message');
				this.selectPage(n);
				//处理完后可以手动条用selectPage进行页码选中切换

			},
			//getHref是在click模式下链接算法，一般不需要配置，默认代码如下
			getHref : function(n){
				return '#';
			}

		});
    </script>
</body>
</html>
